package com.sfx.distributeLockStock.controller;

import com.sfx.distributeLockStock.dao.po.StockPO;
import com.sfx.distributeLockStock.service.IStockService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-11-19
 * Time: 11:33
 */
@RestController
@RequestMapping("/stock")
public class StockController {

    @Resource
    private IStockService stockService;

    @GetMapping("/getStock")
    public void getStock() {
        List<StockPO> stockPOS = stockService.selectAll();
        System.out.println(stockPOS);
    }

    @GetMapping("/decrementStock/{goods_id}/{count}")
    public String decrementStock(@PathVariable("goods_id") Integer goodsId,
                               @PathVariable("count") Integer count) {
        return stockService.decrementStock(goodsId,count);
    }
}